<template>
  <div class="home">
    <section class="hero">
      <div class="hero-content">
        <h1>欢迎来到我的博客</h1>
        <p>记录技术学习与生活感悟，分享知识与经验</p>
      </div>
    </section>
    
    <section class="intro">
      <div class="intro-content">
        <div class="avatar">
          <img src="https://picsum.photos/200/200?random=1" alt="头像" />
        </div>
        <div class="intro-text">
          <h2>关于我</h2>
          <p>一名热爱技术的开发者，专注于前端开发和用户体验设计。喜欢探索新技术，分享学习心得。</p>
          <p>在这里，我会记录技术学习过程中的思考与实践，也会分享生活中的点滴感悟。</p>
        </div>
      </div>
    </section>
    
    <section class="latest-articles">
      <h2>最新文章</h2>
      <div class="articles-grid">
        <article v-for="article in latestArticles" :key="article.id" class="article-card">
          <img :src="article.image" :alt="article.title" />
          <div class="article-content">
            <h3>{{ article.title }}</h3>
            <p>{{ article.summary }}</p>
            <div class="article-meta">
              <span>{{ article.date }}</span>
              <router-link :to="`/article/${article.id}`">阅读更多</router-link>
            </div>
          </div>
        </article>
      </div>
    </section>
  </div>
</template>

<script setup>
const latestArticles = [
  {
    id: 1,
    title: 'Vue3 组合式 API 最佳实践',
    summary: '深入探讨 Vue3 组合式 API 的使用技巧和最佳实践，提升开发效率。',
    date: '2024-01-15',
    image: 'https://picsum.photos/300/200?random=2'
  },
  {
    id: 2,
    title: '现代 CSS 布局技术详解',
    summary: '从 Flexbox 到 Grid，全面解析现代 CSS 布局技术的应用场景。',
    date: '2024-01-10',
    image: 'https://picsum.photos/300/200?random=3'
  },
  {
    id: 3,
    title: 'JavaScript 性能优化指南',
    summary: '分享 JavaScript 性能优化的实用技巧和工具使用方法。',
    date: '2024-01-05',
    image: 'https://picsum.photos/300/200?random=4'
  }
]
</script>

<style scoped>
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 4rem 2rem;
  text-align: center;
  border-radius: 10px;
  margin-bottom: 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.2rem;
  opacity: 0.9;
}

.intro {
  background: white;
  padding: 3rem 2rem;
  border-radius: 10px;
  margin-bottom: 3rem;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.intro-content {
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.avatar img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
}

.intro-text h2 {
  color: #2c3e50;
  margin-bottom: 1rem;
}

.intro-text p {
  margin-bottom: 1rem;
  color: #666;
}

.latest-articles h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: #2c3e50;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.article-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  transition: transform 0.3s;
}

.article-card:hover {
  transform: translateY(-5px);
}

.article-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.article-content {
  padding: 1.5rem;
}

.article-content h3 {
  color: #2c3e50;
  margin-bottom: 1rem;
}

.article-content p {
  color: #666;
  margin-bottom: 1rem;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #999;
}

.article-meta a {
  color: #3498db;
  text-decoration: none;
}

@media (max-width: 768px) {
  .intro-content {
    flex-direction: column;
    text-align: center;
  }
  
  .hero h1 {
    font-size: 2rem;
  }
}
</style>